<?php
namespace app\yunda\admin;

use app\common\builder\ZBuilder;
use think\Db;

/**
 * Class Category用户支付记录
 * @package app\yunda\admin
 */
class Fee extends Base{
    public function index()
    {
        // 获取查询和排序规则
        $map = $this->getMap();
        $order = $this->getOrder();
        $map['yd_zhifu_order.delete_time']=NULL;
        //halt($map);
        $data = Db::view('yd_zhifu_order',true)
             ->view('yd_user','nickname','yd_user.openid=yd_zhifu_order.openid','left')
            ->where($map)
            ->order($order)
            ->order('yd_zhifu_order.id desc')
            ->paginate()->each(function($item){
                if($item['status']==1){
                    $item['status']='待支付';
                }else{
                    $item['status']='已支付';
                }
                return $item;
            });
        return ZBuilder::make('table')
            ->setTableName('yd_zhifu_order')  //需要修改 这里修改正确可以直接修改字段 删除
            ->addColumns([
                ['id','id'],
                ['nickname','用户'],
                ['order_sn','支付单号'],
                ['money','支付金额'],
                ['remark','支付用途'],
                ['pay_id','支付物品id'],
                ['status','支付状态'],
                ['create_time','创建时间','datetime'],
                //['right_button', '操作', 'btn']
            ])
            //->addTopButton('add', [],[])
            //->addRightButton('edit',[],[])
            ->addTopButtons(['delete'])
            ->setRowList($data)
            ->addFilter(['name' => 'yd_user'])
            ->setSearch(['id' => 'ID'])
            ->fetch();
    }

}